package com.tcfvic.client.panels;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.VerticalSplitPanel;
import com.tcfvic.client.CompanyDetailsListService;
import com.tcfvic.client.CompanyDetailsListServiceAsync;
import com.tcfvic.client.panels.widgets.CompanyDetailsInputWidget;
import com.tcfvic.client.panels.widgets.CompanyDetailsListWidget;

public class CompanyDetailsForm {

	/**
	 * Create a remote service proxy to talk to the server-side CompanyDetails
	 * service.
	 */
	private final CompanyDetailsListServiceAsync companyDetailsListService = GWT
			.create(CompanyDetailsListService.class);
	private VerticalSplitPanel vSplit = new VerticalSplitPanel();

	public CompanyDetailsForm(boolean editing) {
		// Create a Vertical Split Panel
		vSplit = new VerticalSplitPanel();
		vSplit.ensureDebugId("cwVerticalSplitPanel");
		vSplit.setSize("900px", "800px");
		vSplit.setSplitPosition("1%");

		CompanyDetailsInputWidget companyDetails = new CompanyDetailsInputWidget();
		CompanyDetailsListWidget companyDetailsList = null;
		if (editing) {
			companyDetailsList = new CompanyDetailsListWidget(
					companyDetailsListService, companyDetails);
			vSplit.setTopWidget(companyDetailsList);
			vSplit.setSplitPosition("40%");
		}
		companyDetails.addCompanyDetailsList(companyDetailsList);
		vSplit.setBottomWidget(companyDetails);

	}

	public VerticalSplitPanel getvSplit() {
		return vSplit;
	}
}
